package org.fight.bean;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.fight.logic.fightbo.FightPlayer;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

/**
 * @author : DengYing
 * @CreateDate : 2018年2月28日 下午3:39:42
 * @Description ：战斗抽象
 */
public class AbstractFight {
	/** 战斗ID */
	private String fightId;

	/** 战斗状态 */
	private FightStatusEnum status = FightStatusEnum.AWAIT;

	/** 创建战斗时间 */
	private Date createDate = new Date();

	/** 当前帧 */
	private NetFrame currentFrame = new NetFrame(1);

	/** 网络帧 */
	private List<NetFrame> netFrames = Lists.newArrayList();

	/** 参战玩家 */
	private List<FightPlayer> fightPlayers = Lists.newArrayList();

	/** 需要战斗人数 */
	private int needFightPlayerCount;

	public AbstractFight(String fightId, int needFightPlayerCount) {
		super();
		this.fightId = fightId;
		this.needFightPlayerCount = needFightPlayerCount;
	}

	public String getFightId() {
		return fightId;
	}

	public void setFightId(String fightId) {
		this.fightId = fightId;
	}

	public FightStatusEnum getStatus() {
		return status;
	}

	public void setStatus(FightStatusEnum status) {
		this.status = status;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public NetFrame getCurrentFrame() {
		return currentFrame;
	}

	public void setCurrentFrame(NetFrame currentFrame) {
		this.currentFrame = currentFrame;
	}

	public List<NetFrame> getNetFrames() {
		return netFrames;
	}

	public void setNetFrames(List<NetFrame> netFrames) {
		this.netFrames = netFrames;
	}

	public List<FightPlayer> getFightPlayers() {
		return fightPlayers;
	}

	public void setFightPlayers(List<FightPlayer> fightPlayers) {
		this.fightPlayers = fightPlayers;
	}

	public int getNeedFightPlayerCount() {
		return needFightPlayerCount;
	}

	public void setNeedFightPlayerCount(int needFightPlayerCount) {
		this.needFightPlayerCount = needFightPlayerCount;
	}

	/**
	 * 网络帧
	 */
	public static final class NetFrame {
		/** 帧索引 */
		private int index;

		/** 操作帧 */
		private List<OperateFrame> operateFrame = Lists.newArrayList();

		public NetFrame(int index) {
			super();
			this.index = index;
		}

		public int getIndex() {
			return index;
		}

		public void setIndex(int index) {
			this.index = index;
		}

		public List<OperateFrame> getOperateFrame() {
			return operateFrame;
		}

		public void setOperateFrame(List<OperateFrame> operateFrame) {
			this.operateFrame = operateFrame;
		}
	}

	/**
	 * 操作帧
	 * 
	 * @author win7
	 *
	 */
	public static final class OperateFrame {
		private int pid;

		/** 按键键值 （摇杆、按键） */
		private int keyCode;

		/** 按键状态 down/doing/up/摇杆角度 */
		private int keyEvent;

		public OperateFrame(int pid, int keyCode, int keyEvent) {
			super();
			this.pid = pid;
			this.keyCode = keyCode;
			this.keyEvent = keyEvent;
		}

		public int getPid() {
			return pid;
		}

		public void setPid(int pid) {
			this.pid = pid;
		}

		public int getKeyCode() {
			return keyCode;
		}

		public void setKeyCode(int keyCode) {
			this.keyCode = keyCode;
		}

		public int getKeyEvent() {
			return keyEvent;
		}

		public void setKeyEvent(int keyEvent) {
			this.keyEvent = keyEvent;
		}

	}
}
